Skip to content

fix(oauth): de-duplicate deep-link handling + quiet status-poll log - #189

Merged
its-mash merged 2 commits into
mainfrom
fix/deep-link-dedupe-status-throttle
Jun 25, 2026
Merged

fix(oauth): de-duplicate deep-link handling + quiet status-poll log#189
its-mash merged 2 commits into
mainfrom
fix/deep-link-dedupe-status-throttle

Conversation

@its-mash

Copy link
Copy Markdown
Member

From investigating a report that OAuth approval felt slow / status was slow to update.

What was actually wrong (and fixed)

Deep link processed twice per approval. On a warm launch the approval deep link (mcpmux://authorize?request_id=…) is delivered by both the deep-link plugin's on_open_url and the single-instance callback, so the consent flow ran twice — two get_pending_consent calls and a duplicate consent emit per approval (visible in logs as back-to-back [OAuth] Fetching pending consent).

  • handle_deep_link now drops a repeat of the same URL within a 3s window (deep_link_is_duplicate, backed by the pure, unit-tested is_recent_duplicate_link). Distinct authorizations carry a fresh request_id, so legitimate back-to-back flows are never collapsed. 4 unit tests.

Status-poll log spam. The UI polls get_gateway_status on a timer and on every domain event; at INFO it floods the log (several lines/sec) and buries real events. Lowered to DEBUG.

What this does NOT fix (and why)

The post-approval 5–30s delay you saw is not in the gateway. Traced against the log: approval → code → token are all sub-millisecond server-side; the redirect to the client's cursor:// URL is handed to the OS via ShellExecuteW (returns in ~0.5s). The remaining time is the Windows shell routing the cursor:// custom scheme + Cursor's own callback handling/timeout-retry — outside mcpmux. The code is bound to the cursor:// redirect_uri Cursor itself requested, so the gateway can't reroute it. Also confirmed: the roots fetch runs in a spawned task (never blocks the handshake; succeeded on attempts=1), so the "root report delay" is not a factor.

Follow-up (not in this PR): the frontend status polling is multi-caller and event-driven; consolidating those callers would cut call volume, but it's a separate frontend refactor.

https://claude.ai/code/session_01Baan9JmzR43uxxRUh7CAMF

its-mash added 2 commits June 25, 2026 16:22
On a warm launch the OAuth approval deep link (mcpmux://authorize?request_id=…)
is delivered twice — once by the deep-link plugin's on_open_url and again by
the single-instance callback — so the whole consent flow ran twice per
approval (duplicate consent emit + two get_pending_consent calls, visible in
logs as back-to-back "[OAuth] Fetching pending consent").

- Drop a repeat of the same deep-link URL within a 3s window
  (`deep_link_is_duplicate`, gated by the pure, unit-tested
  `is_recent_duplicate_link`). Distinct authorizations carry a fresh
  request_id, so legitimate back-to-back flows are never collapsed.
- Lower the per-call `get_gateway_status` log from INFO to DEBUG: the UI polls
  it on a timer and on every domain event, flooding the log (several lines/sec)
  and burying the events that matter.

Note: this does not change the post-approval latency. Server-side, approval →
code → token are all sub-millisecond; the redirect to a `cursor://` URL is
handed to the OS via ShellExecuteW (returns in ~0.5s) and the remaining
delay is the Windows shell routing the custom scheme + the client's own
callback handling — outside the gateway.

Claude-Session: https://claude.ai/code/session_01Baan9JmzR43uxxRUh7CAMF
Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
@its-mash
its-mash merged commit 9dd7b58 into main Jun 25, 2026
13 checks passed
@its-mash
its-mash deleted the fix/deep-link-dedupe-status-throttle branch June 25, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant